<?php

/**
 * Menashop
 *
 * LICENSE
 *
 * This source file is subject to the license that is bundled
 * with this project in the file LICENSE.txt
 *
 * @category   Zend
 * @package    Admin_Model
 * @subpackage FormInvoices
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 * @version    1.0.0
 * @since      File available since Release 1.0.0
 */

/**
 * The form for invoices
 * 
 * @category   Zend
 * @package    Admin_Model
 * @subpackage FromInvoices
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 */
class Admin_Model_FormInvoices extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');

        $page = new Zend_Form_Element_Text('page');
        $page->removeDecorator('label');
        $page->removeDecorator('htmlTag');
        $page->removeDecorator('Errors');
        $this->addElement($page);

        $rows = new Zend_Form_Element_Select('rows');
        $rowsOnPage = array('20', '50', '100');
        foreach ($rowsOnPage as $value) {
            $rows->addMultiOption($value, $value);
        }
        $rows->removeDecorator('label');
        $rows->removeDecorator('htmlTag');
        $rows->removeDecorator('Errors');
        $this->addElement($rows);

        $recordsCount = new Zend_Form_Element_Text('records_count');
        $this->addElement($recordsCount);

        $pagesCount = new Zend_Form_Element_Text('pages_count');
        $this->addElement($pagesCount);

        $sort = new Zend_Form_Element_Hidden('sort');
        $sort->removeDecorator('label');
        $sort->removeDecorator('htmlTag');
        $sort->removeDecorator('Errors');
        $this->addElement($sort);

        $direction = new Zend_Form_Element_Hidden('direction');
        $direction->removeDecorator('label');
        $direction->removeDecorator('htmlTag');
        $direction->removeDecorator('Errors');
        $this->addElement($direction);

        $id = new Zend_Form_Element_Text('id');
        $id->removeDecorator('label');
        $id->removeDecorator('htmlTag');
        $id->removeDecorator('Errors');
        $this->addElement($id);

        $toName = new Zend_Form_Element_Text('to_name');
        $toName->removeDecorator('label');
        $toName->removeDecorator('htmlTag');
        $toName->removeDecorator('Errors');
        $toName->setAttrib('class', 'text-field');
        $this->addElement($toName);

        $amountFrom = new Zend_Form_Element_Text('amount_from');
        $amountFrom->removeDecorator('label');
        $amountFrom->removeDecorator('htmlTag');
        $amountFrom->removeDecorator('Errors');
        $amountFrom->setAttrib('class', 'number-field');
        $this->addElement($amountFrom);

        $amountTo = new Zend_Form_Element_Text('amount_to');
        $amountTo->removeDecorator('label');
        $amountTo->removeDecorator('htmlTag');
        $amountTo->removeDecorator('Errors');
        $amountTo->setAttrib('class', 'number-field');
        $this->addElement($amountTo);

        $createdFrom = new Zend_Form_Element_Text('created_from');
        $createdFrom->removeDecorator('label');
        $createdFrom->removeDecorator('htmlTag');
        $createdFrom->removeDecorator('Errors');
        $createdFrom->setAttrib('class', 'date-field');
        $this->addElement($createdFrom);

        $createdTo = new Zend_Form_Element_Text('created_to');
        $createdTo->removeDecorator('label');
        $createdTo->removeDecorator('htmlTag');
        $createdTo->removeDecorator('Errors');
        $createdTo->setAttrib('class', 'date-field');
        $this->addElement($createdTo);

        $updatedFrom = new Zend_Form_Element_Text('updated_from');
        $updatedFrom->removeDecorator('label');
        $updatedFrom->removeDecorator('htmlTag');
        $updatedFrom->removeDecorator('Errors');
        $updatedFrom->setAttrib('class', 'date-field');
        $this->addElement($updatedFrom);

        $updatedTo = new Zend_Form_Element_Text('updated_to');
        $updatedTo->removeDecorator('label');
        $updatedTo->removeDecorator('htmlTag');
        $updatedTo->removeDecorator('Errors');
        $updatedTo->setAttrib('class', 'date-field');
        $this->addElement($updatedTo);

        $orderId = new Zend_Form_Element_Text('order_id');
        $orderId->removeDecorator('label');
        $orderId->removeDecorator('htmlTag');
        $orderId->removeDecorator('Errors');
        $orderId->setAttrib('class', 'number-field');
        $this->addElement($orderId);

        $status = new Zend_Form_Element_Select('status');
        $status->addMultiOption('', '');
        $invoiceStatusModel = new Admin_Model_InvoiceStatus();
        $invoiceStatuses = $invoiceStatusModel->fetchAllPairs();
        foreach ($invoiceStatuses as $key => $value) {
            $status->addMultiOption($key, $value);
        }

        $status->removeDecorator('label');
        $status->removeDecorator('htmlTag');
        $status->removeDecorator('Errors');
        $status->setAttrib('class', 'text-field');
        $this->addElement($status);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Search');
        $submit->setAttrib('id', 'search-button');
        $submit->removeDecorator('DtDdWrapper');
        $this->addElement($submit);

        $this->setDecorators(array(array('ViewScript', array('viewScript' => '_form_invoices.phtml'))));
    }

}

